package com.econ.powercloud.ems.common.enums;

/**
 * mqtt 发送方类型
 *
 * @author chenxiaoqi
 * @since 2021/10/12
 */
public enum EdgeSendSourceMsgType implements EnumMethod {

    /**  */
    FROM_IOT_CLOUD(1, "IOT平台发起消息"),
    FROM_DEVICE(2, "设备端发起消息"),
    FROM_MQTT_BROKER(3, "来自mqtt broker自动发送的消息"),
    FROM_LOCAL(4, "来自就地系统"),
    FROM_PARTY3(5, "第三方云")
    ;

    private final Integer code;
    private final String desc;

    EdgeSendSourceMsgType(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    public static EdgeSendSourceMsgType fromCode(int code){
        for(EdgeSendSourceMsgType types: EdgeSendSourceMsgType.values()){
            if(types.getCode() == code){
                return types;
            }
        }
        return EdgeSendSourceMsgType.FROM_IOT_CLOUD;
    }
}
